<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>匀速运动</title>
</head>
<style>
    .box{
        width: 100px;
        height: 100px;
        background-image: -webkit-radial-gradient(yellow,green,pink,blue,red,black);
        /* 径向渐渐变 */
        border-radius: 50%;
        box-shadow: 2px 3px 4px 4px coral;
           /* 给元素添加阴影 */
        position: absolute;
        left:0px;
     
   }
</style>
<body>
    <!-- 匀速运动物体在单位时间内所通过的距离相等的运动 -->
    <div class="box">
    </div>
    <script>
         var box = document.querySelector('.box');
        // 鼠标滑过 box的让元素移动到1000的位置
        var left = 0;
        box.onmouseover = function () {
            // 一瞬间移动过去
            // box.style.left = '1000px';   
            let timer = setInterval(() => {
                // 每执行一次就 +10
                left += 3;
                // 结束条件
                if (left >= 1000) {
                    left = 1000;
                    clearInterval(timer)
                }
                box.style.left = left + 'px';
            }, 10)
        }
    </script>
</body>
</html>